/* License Notice:
**
** This program is free software: you can redistribute it and/or modify
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation, either version 3 of the License, or
**    (at your option) any later version.
** This program is distributed in the hope that it will be useful,
**   but WITHOUT ANY WARRANTY; without even the implied warranty of
**   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
**   GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
**   along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
 * @file text_box.hpp
 * @author TooOld2Rock'nRoll
 * @date 2025/03/21
 * @brief Implements a TextBox (a string to be rendered) for the ArcadeFighter library.
 *
 * @todo For now, we are just changing each letter to print on the fly, but we should do texture blitting when the string changes!
 *       Than we can unhide getTexture()!!
 * @todo Add cropByStrLen(), good for dialog animations and such......
 * @todo Consider supporting Markdown syntax.
 * @bug possible bug, we don't know if the sprite bounding box is actually being respected since glyph move all around with kerneling!
 */
#ifndef _TEXT_TEXTBOX_HPP_
#define _TEXT_TEXTBOX_HPP_

/*---- Includes ----*/
#include "graphics/font.hpp"
#include "graphics/sprite2D.hpp"


/*---- Class Declaration ----*/
/**
 * @brief TextBox class for the ArcadeFighter library.
 * @extends Sprite2D
 * @see https://www.khronos.org/opengl/wiki/Framebuffer
 *
 * This class will render a string of characters using the provided Font.<br>
 * It will correctly process <b>new line</b> and <b>carriage return</b> characters.<br>
 *
 * It differs from a normal sprite as it has "two textures", one being the source Font and the other the actual texture
 *    containing the string to be rendered. This process is built using FrameBuffers with a technique know as
 *    <i>Blitting</i>, where we "stitch" together parts from a Texture to create another.<br>
 * This will result two different sets of tiles, one for the Font (which maps the font's glyph) and one for the TextBox
 *    (which maps the string), making it possible to crop/animate the text box in various ways.
 */
class TextBox : public Sprite2D
{
    private:
        Font *p_font = nullptr;

        std::string s_lable = "";


    protected:
        using Sprite2D::setTexture;


    public:
        TextBox ();
        virtual ~TextBox ();

        /** @brief Sets a Font to be used by the TextBox to render text. */
        void setFont (Font *f);
        /** @brief Gets a pointer to the Font being used by this TextBox. */
        Font* getFont () const { return this->p_font; }

        void setString (std::string label);
        /** @brief Gets the string being used as label. */
        const char * getString () const { return this->s_lable.c_str (); }
};//END TextBox

#endif //_TEXT_TEXTBOX_HPP_

